package com.bigcms.utils;

import com.fasterxml.jackson.annotation.JsonInclude;

public class JsonData {
    private int code;
    private String msg;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Object data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public JsonData() {
    }

    public JsonData(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public JsonData(int code, Object data) {
        this.code = code;
        this.data = data;
    }
    public JsonData(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    static public JsonData Success(){
        return new JsonData(1,"操作成功");
    }
    static public JsonData Success(String data){
        return new JsonData(1,data);
    }
    static public JsonData Success(Object data){
        return new JsonData(1,"操作成功",data);
    }
    static public JsonData Error(){
        return new JsonData(0,"操作失败");
    }
    static public JsonData Error(String msg){
        return new JsonData(0,msg);
    }
    static public JsonData Error(Object data){
        return new JsonData(0,"操作失败",data);
    }
    static public JsonData Return(int code, String msg){
        return new JsonData(code,msg);
    }
    static public JsonData Return(int code, String msg,Object data){
        return new JsonData(code,msg,data);
    }
}
